<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <div id="app">
    姓：<input v-model="userName" type="text"><br>
    名：<input v-model="passName" type="text"><br>
    <p>姓名：{{allName}}</p>
    <button @click="allName='王宁'">修改姓名</button>
  </div>
  <script src="./vue.js"></script>
  <script>
    const app = new Vue({
      el: '#app',
      data: {
          userName:'', //姓
          passName:'' //名
      },
      computed:{
        allName:{
          get(){
            return this.userName + this.passName
          },
          set(value){
            this.userName = value.slice(0,1)  //选取下标0的值
            this.passName = value.slice(1)  //选取下标1的值
          }
        }
      
      }
    })
  </script>
</body>
</html>